﻿using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml.Schema;
namespace ScormModel
{
    [Serializable()]
    public class RollupConditions
    {
        private string _conditionCombination;
        [NonSerialized]
        private XmlNode _rollupConditionsContent;
        private List<RollupCondition> _listRollupCondition;
        [XmlAttribute("conditionCombination")]
        public string ConditionCombination
        {
            get { return this._conditionCombination; }
            set { this._conditionCombination = value; }
        }
        [XmlElement("rollupCondition", Namespace = "http://www.imsglobal.org/xsd/imsss")]
        public List<RollupCondition> ListRollupCondition
        {
            get { return this._listRollupCondition; }
            set { this._listRollupCondition = value; }
        }
        
        [XmlIgnoreAttribute]
        public XmlNode RollupConditionsContent
        {
            get { return this._rollupConditionsContent; }
            set { this._rollupConditionsContent = value; }
        }
        public void buildRollupConditions()
        {
            if ((XmlAttribute)_rollupConditionsContent.Attributes.GetNamedItem("conditionCombination") != null)
            {
                _conditionCombination = ((XmlAttribute)_rollupConditionsContent.Attributes.GetNamedItem("conditionCombination")).Value;
            }
            _listRollupCondition = new List<RollupCondition>();
            for (int i = 0; i < _rollupConditionsContent.ChildNodes.Count; i++)
            {
                if (((XmlNode)(_rollupConditionsContent.ChildNodes[i])).Name == "imsss:rollupCondition")
                {
                    RollupCondition rollupCondition = new RollupCondition();
                    rollupCondition.RollupConditionContent = (XmlNode)(_rollupConditionsContent.ChildNodes[i]);
                    rollupCondition.buildRollupCondition();
                    _listRollupCondition.Add(rollupCondition);
                }
            }
        }
    }
}
